import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

/**
 * @ClassName : AdjMatrix
 * @Author : 骆发茂
 * @Date: 2021/11/12 18:47
 * @Description : 生成二维矩阵
 */
public class AdjMatrix {
    private int E;//边
    private int V;//顶点
    private int[][] adj;

    public AdjMatrix(String filename) {
        File file = new File(filename);
        try (Scanner scanner = new Scanner(file)
        )
        {
            V = scanner.nextInt();
            //创建一个V横,V竖的二维数组
            adj = new int[V][V];

            E = scanner.nextInt();

            //E是边，多少条边
            for (int i = 0; i < E; i++) {
                int a = scanner.nextInt();
                int b = scanner.nextInt();
                //关于主对角线堆对称
                adj[a][b] = 1;
                adj[b][a] = 1;
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

    }


    @Override
    public String toString() {

        StringBuilder sb = new StringBuilder();
        //告诉顶点、边
        sb.append(String.format("V = %d, E =%d\n", V, E));
        //每一行
        for (int i = 0; i < V; i++) {
            //每一列
            //每行每列都循环一边
            for (int j = 0; j < V; j++) {

                sb.append(String.format("%d ", adj[i][j]));

            }
            sb.append('\n');

        }
        return sb.toString();

    }

    public static void main(String[] args) {

        AdjMatrix adjMatrix = new AdjMatrix("g.txt");
        System.out.println(adjMatrix);

    }
}